Skip to content

Rust crate updates 2026-05-05#10402

Open
holtrop-wolfssl wants to merge 14 commits intowolfSSL:masterfrom
holtrop-wolfssl:rust-crate-updates-2026-05-05
Open

Rust crate updates 2026-05-05#10402
holtrop-wolfssl wants to merge 14 commits intowolfSSL:masterfrom
holtrop-wolfssl:rust-crate-updates-2026-05-05

Conversation

@holtrop-wolfssl
Copy link
Copy Markdown
Contributor

@holtrop-wolfssl holtrop-wolfssl commented May 5, 2026

Description

This PR includes several Fenrir fixes and some new functionality I found missing during my integration tests with boringtun.

See the commits for individual descriptions of each change.

Testing

Unit/CI tests.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@holtrop-wolfssl holtrop-wolfssl self-assigned this May 5, 2026
Copilot AI review requested due to automatic review settings May 5, 2026 20:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the wolfssl-wolfcrypt Rust wrapper to (1) improve RNG lifetime safety across FFI consumers, (2) add RustCrypto trait integrations for BLAKE2 digest/MAC, and (3) extend AEAD support with AES-192 CCM/GCM wrappers, along with corresponding test updates.

Changes:

  • Refactors RNG to own a C-heap WC_RNG* and updates RNG-taking APIs to accept &RNG (plus new set_shared_rng(Arc<RNG>) for consumers that store an RNG pointer internally).
  • Adds RustCrypto digest::Digest wrappers (blake2_digest) and digest::Mac wrappers (blake2_mac) for BLAKE2b/BLAKE2s.
  • Adds AEAD wrappers and tests for AES-192-GCM and AES-192-CCM, and adds Clone support for HMAC MAC types.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wrapper/rust/wolfssl-wolfcrypt/tests/test_rsa.rs Updates tests to new RNG borrowing/sharing patterns (&RNG, set_shared_rng).
wrapper/rust/wolfssl-wolfcrypt/tests/test_random.rs Updates RNG tests to match RNG methods taking &self (no mut).
wrapper/rust/wolfssl-wolfcrypt/tests/test_hmac_mac.rs Adds a clone/forking test to validate cloned HMAC MAC state equivalence.
wrapper/rust/wolfssl-wolfcrypt/tests/test_ecc.rs Updates ECC tests for RNG ownership and shared RNG binding.
wrapper/rust/wolfssl-wolfcrypt/tests/test_curve25519.rs Updates Curve25519 tests for conditional RNG sharing when blinding is enabled.
wrapper/rust/wolfssl-wolfcrypt/tests/test_blake2_mac.rs Adds MAC trait tests for BLAKE2b/BLAKE2s keyed constructions.
wrapper/rust/wolfssl-wolfcrypt/tests/test_blake2_digest.rs Adds Digest trait tests for typed BLAKE2b/BLAKE2s hashers.
wrapper/rust/wolfssl-wolfcrypt/tests/test_aes.rs Adds AES-192-GCM/CCM AEAD roundtrip tests.
wrapper/rust/wolfssl-wolfcrypt/src/rsa.rs Refactors RSA RNG usage (&RNG params, owned/shared RNG binding stored to ensure lifetime).
wrapper/rust/wolfssl-wolfcrypt/src/rsa_pkcs1v15.rs Updates RSA PKCS#1v1.5 signing wrapper to new RNG pointer model.
wrapper/rust/wolfssl-wolfcrypt/src/random.rs Refactors RNG to own WC_RNG* allocated via wc_rng_new_ex, updates methods to take &self.
wrapper/rust/wolfssl-wolfcrypt/src/mlkem.rs Updates ML-KEM APIs to accept &RNG and pass WC_RNG* through FFI.
wrapper/rust/wolfssl-wolfcrypt/src/lms.rs Updates LMS keygen to accept &RNG.
wrapper/rust/wolfssl-wolfcrypt/src/lib.rs Adds alloc support and conditionally exports new BLAKE2 digest/MAC modules.
wrapper/rust/wolfssl-wolfcrypt/src/hmac.rs Implements deep Clone for HMAC via wc_HmacCopy.
wrapper/rust/wolfssl-wolfcrypt/src/hmac_mac.rs Derives Clone for HMAC MAC wrapper types.
wrapper/rust/wolfssl-wolfcrypt/src/ed448.rs Updates Ed448 key generation to accept &RNG.
wrapper/rust/wolfssl-wolfcrypt/src/ed25519.rs Updates Ed25519 key generation to accept &RNG.
wrapper/rust/wolfssl-wolfcrypt/src/ecdsa.rs Adapts ECDSA wrapper FFI calls to ECC key pointer storage changes.
wrapper/rust/wolfssl-wolfcrypt/src/ecc.rs Refactors ECC to store a C-heap ecc_key* and adds owned/shared RNG binding.
wrapper/rust/wolfssl-wolfcrypt/src/dilithium.rs Updates Dilithium APIs to accept &RNG.
wrapper/rust/wolfssl-wolfcrypt/src/dh.rs Updates DH APIs to accept &RNG.
wrapper/rust/wolfssl-wolfcrypt/src/curve25519.rs Updates Curve25519 APIs to accept &RNG, adds RNG ownership/sharing for blinding.
wrapper/rust/wolfssl-wolfcrypt/src/blake2_mac.rs Adds RustCrypto Mac trait wrappers for keyed BLAKE2b/BLAKE2s.
wrapper/rust/wolfssl-wolfcrypt/src/blake2_digest.rs Adds RustCrypto Digest trait wrappers for typed BLAKE2b/BLAKE2s hashers.
wrapper/rust/wolfssl-wolfcrypt/src/aes.rs Adds AES-192 CCM/GCM AEAD wrappers.
wrapper/rust/wolfssl-wolfcrypt/Makefile Enables the new alloc feature in the Makefile feature set.
wrapper/rust/wolfssl-wolfcrypt/Cargo.toml Replaces std feature with alloc and keeps feature list in sync with new APIs/modules.
Comments suppressed due to low confidence (1)

wrapper/rust/wolfssl-wolfcrypt/Cargo.toml:22

  • This change removes the previously exported std feature and adds a new alloc feature. Together with the public API signature changes in this PR (e.g., set_rng/generate now taking RNG or &RNG instead of &mut RNG), this is a semver-breaking change for a 1.x crate. Consider either (a) bumping the crate major version, or (b) keeping std as a backwards-compatible feature alias to alloc and providing compatibility shims where practical.
[features]
alloc = []
rand_core = ["dep:rand_core"]
aead = ["dep:aead"]
cipher = ["dep:cipher"]
mac = ["digest/mac"]
digest = ["dep:digest"]
signature = ["dep:signature"]
password-hash = ["dep:password-hash", "password-hash/phc"]
kem = ["dep:kem", "hybrid-array/extra-sizes"]

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wrapper/rust/wolfssl-wolfcrypt/src/ecc.rs Outdated
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/ecc.rs Outdated
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/rsa.rs Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

MemBrowse Memory Report

No memory changes detected for:

- store pointer to WC_RNG instead of full struct
- enforce RNG is not dropped before consumer structs

The C library stores a pointer via the set_rng() methods on a few
structs (e.g. RSA). This change holds a reference (or instance) of RNG
within the consumer structs to ensure it is kept alive if set_rng (or
now set_shared_rng) is used.
This fixes internal pointers breaking if Rust moves the ECC struct (with
some build configurations).
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/rsa.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/tests/test_ecc.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/ecc.rs
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/ecc.rs Outdated
Comment thread wrapper/rust/wolfssl-wolfcrypt/src/ecc.rs
@gasbytes gasbytes removed their assignment May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants